package com.zr.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.annotation.Resource;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.zr.service.SelectOrdersService;

import net.sf.json.JSONObject;

@Controller
@Scope(value="prototype")
public class SelectOrdersAction implements ServletResponseAware{
	private ServletResponse req;
	
	private int page;
	private int rows;
	
	public int getPage() {
		return page;
	}
	public void setPage(int page) {
		this.page = page;
	}
	public int getRows() {
		return rows;
	}
	public void setRows(int rows) {
		this.rows = rows;
	}

	@Resource
	private  SelectOrdersService selectOrdersService;
public void selectOrders(){	
	try {
		
		req.setCharacterEncoding("utf8");
		JSONObject jy=selectOrdersService.findOrdersMsg(page, rows);
		PrintWriter ps=req.getWriter();
		 ps.write(jy.toString());
		
	} catch (IOException e) {
		e.printStackTrace();
	}
}
public void selectCar1(){
	
	try {
		
		System.out.println(page);
		System.out.println(rows);
		req.setCharacterEncoding("utf8");
		JSONObject jy=selectOrdersService.findCar(page, rows);
		PrintWriter ps=req.getWriter();
		 ps.write(jy.toString());
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}

@Override
public void setServletResponse(HttpServletResponse Response) {
	this.req=Response;
	
}

}
